<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core"  prefix="c"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>导航树</title>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">   
	<meta http-equiv="X-UA-Compatible" content="IE=edge" /> 
	<link  href="${pageContext.request.contextPath}/app/css/style.css" rel="stylesheet"  type="text/css"/>
	<script src="${pageContext.request.contextPath}/app/js/jquery-1.7.min.js" type="text/javascript"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/app/js/tree_panle.js" ></script> 
<style>
html{ height:100%;overflow: hidden; }
body{ height:100%; overflow: hidden; background:url(${pageContext.request.contextPath}/app/images/main_bg.jpg) repeat-x;padding-top:5px;}
</style>
<script type="text/javascript">
  $(function(){
    $('.left_menu').find('dd').eq(0).css('display','block'); //默认展开第一个panel
    $('.left_menu').find('dt').eq(0).addClass('select_panle');//将第一个panel设置为选中样式
    $('.left_menu').find('dt').eq(0).next('dd').find('h1').addClass('open'); //将第一个panel的所有节点设置为打开
    $('.left_menu').find('dd ul a').each(function(index , item){
    	$(item).bind('click',function(){
    		var id = $(this).attr('id')+'_tab';
    		var title = $(this).text();
    		var url = $(this).attr('name');
    		var rightTarget = self.parent.frames['mainFrame'];
    		//新建页签
    		var h = '98%';
    		if($.browser.msie && ($.browser.version == 8.0 || $.browser.version == 9.0)){
    	    	 h = $(self.parent.frames['mainFrame']).height()-35; 
    	    }
    		if(rightTarget.$('#tabs').omTabs('getAlter', id) == undefined){
    			if(url != undefined && url != ''){
		    		rightTarget.$('#tabs').omTabs('add',{
		    			title : title,
		    			tabId : id,
		    			closable : true,
		    			content:"<iframe id='iframe_"+id+"' name='iframe_"+id+"' border=0 frameBorder='no' name='inner-frame' src='"+'${pageContext.request.contextPath}'+url+'?catalogId='+$(this).attr('id')+"' height='"+h+"' width='99%'></iframe>"
		    		});
    			}
    		}else{//页签已经打开，激活打开页签
    			rightTarget.$('#tabs').omTabs('activate', id); 
    		}
    	});
    });
  });
</script>
  </head>
  <body >
     <div class="left_menu">
     	<dl id="panle">
     	  <c:forEach items="${navTreeBean}" var="navTree">
     	     <dt >${navTree.catalog.cnName }</dt>
     	     <c:if test="${ navTree.catalog.isleaf}"> <!-- 如果本身就是叶子节点，则accordion的名字和链接名字相同 -->
     	     <dd>
                	<ul class="tree">
                	  <li>
                	    <a href="javascript:void(0)"  id="${navTree.catalog.id}" name="${navTree.catalog.linkUrl}"><span class="wenjian"></span>${item.catalog.cnName }</a>
                	  </li>
                	</ul>
     	     </c:if>
     	     <dd>
              <ul class="tree">
	     	     <c:forEach items="${navTree.children }" var="item">
	     	         <c:if test="${!item.catalog.isleaf }"> <!-- 如果不是子节点 ,则展示成文件夹-->
	     	           <li>
	     	              <h1>${item.catalog.cnName }</h1>
	     	               <p>
	     	                <c:forEach items="${item.children }" var="leafNode"> <!-- 此菜单只支持3层菜单，到这里已经是最后一层 -->
	     	                   <a href="javascript:void(0)"  id="${leafNode.catalog.id }" name="${leafNode.catalog.linkUrl}">
	     	                     <span class="wenjian"></span>
	     	                     ${leafNode.catalog.cnName }
	     	                   </a>
	     	                </c:forEach>
	     	               </p>
	     	           </li>
	     	         </c:if>
	     	     </c:forEach>
	     	     <li>  <!-- 再次遍历，将子节点统一放到li里面 -->
		     	     <c:forEach items="${navTree.children }" var="item">
		     	         <c:if test="${item.catalog.isleaf }">
		     	               <a href="javascript:void(0)"   id="${item.catalog.id }" name="${item.catalog.linkUrl}"><span class="wenjian"></span>${item.catalog.cnName }</a>
		     	         </c:if>
		     	     </c:forEach>
	     	     </li>
     	     </ul>
     	    </dd>
     	  </c:forEach>
	  </dl>
     </div>
</body>
</html>